package com.hxt.webpasser.util;

import com.hxt.webpasser.utils.StringUtil;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by chuanbo.wei on 2016/11/23.
 */
public class MainTest {

    public static void main(String[] args) {

//        System.out.println(isAccept("http://www.bilibili.com/video/av(.*)","http://www.bilibili.com/video/av4961651"));

        System.out.println(getAvId("http://www.bilibili.com/video/av4961651"));
    }

    public static boolean isAccept(String reg, String url) {

//        String reg=rule.getValue();
        Pattern pa= Pattern.compile(reg);
        Matcher m= pa.matcher(url);

        if(m.find())
        {
            return true;
        }

        return false;
    }

    private static String getAvId(String avCode){
        //http://www.bilibili.com/video/av10113648
        if(!StringUtil.isEmpty(avCode)){
            return avCode.substring(avCode.indexOf("av"));
        }
        return null;
    }
}
